package com.lucun.es_transaction.service.impl;

import com.lucun.es_transaction.entity.UserPayment;
import com.lucun.es_transaction.mapper.UserPaymentMapper;
import com.lucun.es_transaction.service.UserPaymentService;
import com.lucun.es_transaction.util.BaseException;
import com.lucun.es_transaction.util.JwtUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: 郭鑫
 * @catalogue: com.lucun.es_transaction.service.impl
 * @Date: 2021/6/5 16:02
 * @Version: 1.0
 */
@Service
public class UserPaymentServiceImpl implements UserPaymentService {
    @Autowired
    UserPaymentMapper userPaymentMapper;
    @Override
    public List<UserPayment> getProductOrderList(UserPayment userPayment, HttpServletRequest request) {
        if (ObjectUtils.isEmpty(userPayment)){
            throw new BaseException("没有获取数据");
        }
        int idToken = JwtUtil.getIdByToken(request);
        if (ObjectUtils.isEmpty(idToken)){
            throw new BaseException("解析tokenId失败");
        }
        return userPaymentMapper.getUserPaymentList(userPayment.getUserId());
    }
    @Override
    public List<UserPayment> getProductOrderList1() {
        return userPaymentMapper.getUserPaymentList1();
    }
}